package cn.com.http.httpheader;

public abstract class HttpTitle {
	private Object title = null;

	public Object get() {
		return title;
	}

	public String toString() {
		return title == null ? null : title.toString();
	}

	protected final void setTitle(Object title) {
		if (title == null)
			throw new NullPointerException();
		Object[] supported = getSupported();
		if (supported != null) {
			boolean isSupported = false;
			for (Object object : supported) {
				if (object.equals(title)) {
					isSupported = true;
				}
			}
			if (!isSupported)
				throw new IllegalArgumentException(title.toString());
		}
		this.title = title;
	}

	public abstract Object[] getSupported();
}
